package com.example.demo.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.servlet.MultipartConfigElement;

/**
 * @author: star
 * @date: 2020/3/8
 */
@Configuration
public class MyPicConfig implements WebMvcConfigurer {

    @Value("${avatorImagesPath}")
    private String avatorImagesPath;
    @Value("${singerPicPath}")
    private String singerPicPath;
    @Value("${songPicPath}")
    private String songPicPath;
    @Value("${songPath}")
    private String songPath;
    @Value("${songListPicPath}")
    private String songListPicPath;
    @Value("${mvPath}")
    private String mvPath;
    @Value("${bangListPicPath}")
    private String bangListPicPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        System.err.println("载入路径：" + avatorImagesPath);
        System.err.println(songListPicPath);

        registry.addResourceHandler("/avatorImages/**")
                .addResourceLocations(avatorImagesPath);

        registry.addResourceHandler("/img/singerPic/**")
                .addResourceLocations(singerPicPath);

        registry.addResourceHandler("/img/songPic/**")
                .addResourceLocations(songPicPath);

        registry.addResourceHandler("/song/**")
                .addResourceLocations(songPath);

        registry.addResourceHandler("/img/songListPic/**")
                .addResourceLocations(songListPicPath);

        registry.addResourceHandler("/img/bangListPic/**")
                .addResourceLocations(bangListPicPath);

        registry.addResourceHandler("/mv/**")
                .addResourceLocations(mvPath);
    }

}
